const axios = require('axios');
const MockAdapter = require('axios-mock-adapter');
const normalAxios = axios.create();
const mockAxios = axios.create();
import url_config from "./config";
import reqTools from "../utils/reqTools";

// mock 数据   平台 声波锁离线版
var mock = new MockAdapter(mockAxios);

//查询昨天
mock.onGet('/yesterday').reply((config) => {
  return new Promise(function(resolve, reject) {
    reqTools.get('/homepage/yesterdayplatformbalanceLogType',
    config).then((res) => {
      resolve([200, res]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });
});

  //查询上周
  mock.onGet('/lastweek').reply((config) => {
    return new Promise(function(resolve, reject) {
      reqTools.get('/homepage/lastweekplatformbalanceLogType',
      config).then((res) => {
        resolve([200, res]);
      }).catch((err) => {
        resolve([500, err ]);
      });
    });
  });
  
    //查询上月
  mock.onGet('/lastmonth').reply((config) => {
    return new Promise(function(resolve, reject) {
      reqTools.get('/homepage/lastmonthplatformbalanceLogType',
      config).then((res) => {
        resolve([200, res]);
      }).catch((err) => {
        resolve([500, err ]);
      });
    });
  });

      //查询柱状图
  mock.onGet('/querycolumn').reply((config) => {
    return new Promise(function(resolve, reject) {
      reqTools.get('/homepage/column',
      config).then((res) => {
        resolve([200, res]);
      }).catch((err) => {
        resolve([500, err ]);
      });
    });
  });

       //查询曲线图
       mock.onGet('/querycurve').reply((config) => {
        return new Promise(function(resolve, reject) {
          reqTools.get('/homepage/curve',
          config).then((res) => {
            resolve([200, res]);
          }).catch((err) => {
            resolve([500, err ]);
          });
        });
      });

          //查询最近收益
          mock.onGet('/earnings').reply((config) => {
            return new Promise(function(resolve, reject) {
              reqTools.get('/homepage/earnings',
              config).then((res) => {
                resolve([200, res]);
              }).catch((err) => {
                resolve([500, err ]);
              });
            });
          });

//开门率
mock.onGet('/usagerate').reply((config) => {
  return new Promise(function(resolve, reject) {
    reqTools.get('/homepage/usagerate',
    config).then((res) => {
      resolve([200, res]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });
});

export default mockAxios;
